﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="AddFarmer.aspx.cs" Inherits="BillingManagment.AddFarmer" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table cellpadding="0" cellspacing="5" width="750px" style="font-size: medium;">
        <tr>
            <td colspan="3">
                <h1 style="text-align:center"> ADD NEW FARMER</h1>
            </td>
        </tr>
        <tr>
            <td colspan="3">
                <asp:Label ID="lblMsg" runat="server" Style="color: red; font-size: 14px"></asp:Label>
            </td>
        </tr>
        <tr>
            <td style="width: 100px;">
                Name
            </td>
            <td>
                <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="rfv11" runat="server" Display="Dynamic" ControlToValidate="txtName"
                    ValidationGroup="normal" ForeColor="Red" Text="*" ErrorMessage="Enter name of farmer."></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td>
                Address
            </td>
            <td>
                <asp:TextBox ID="txtAddress" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Display="Dynamic"
                    ControlToValidate="txtAddress" ValidationGroup="normal" ForeColor="Red" Text="*"
                    ErrorMessage="Enter address of farmer."></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td>
                Phone No
            </td>
            <td>
                <asp:TextBox ID="txtPhone" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" Display="Dynamic"
                    ControlToValidate="txtPhone" ValidationGroup="normal" ForeColor="Red" Text="*"
                    ErrorMessage="Enter phone number."></asp:RequiredFieldValidator>
            </td>
        </tr>
        <%-- <tr>
            <td>
                Advance Rs
            </td>
            <td>
                <asp:TextBox ID="txtAdvance" runat="server"></asp:TextBox>
            </td>
        </tr>--%>
        <tr>
            <td>
                Other Info
            </td>
            <td>
                <asp:TextBox ID="txtOtherInfo" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" Display="Dynamic"
                    ControlToValidate="txtOtherInfo" ValidationGroup="normal" ForeColor="Red" Text="*"
                    ErrorMessage="Enter other information."></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Button ID="btnSubmit" ValidationGroup="normal" runat="server" Text="Submit"
                    OnClick="btnSubmit_Click" />
                <asp:ValidationSummary ID="vs2" ValidationGroup="normal" ShowSummary="false" ShowMessageBox="true"
                    runat="server" />
            </td>
            <td>
                <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click" />
            </td>
        </tr>
        <tr>
            <td colspan="3">
                <asp:GridView ID="grdFarmer" Width="100%" EmptyDataText="No Record" AutoGenerateColumns="false"
                    runat="server" OnRowCancelingEdit="Cancel" OnRowEditing="Edit" OnRowUpdating="Update">
                    <Columns>
                        <asp:TemplateField HeaderText="Farmer Name" ItemStyle-Width="170px">
                            <ItemTemplate>
                                <%#Eval("Name") %>
                                <asp:Label ID="lbl_ID" runat="server" Visible="false" Text='<%#Eval("ID") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txt_grd_Name" runat="server" Width="150px" Text='<%#Eval("Name") %>'></asp:TextBox>
                                <asp:Label ID="lbl_ID" runat="server" Visible="false" Text='<%#Eval("ID") %>'></asp:Label>
                                <asp:RequiredFieldValidator ID="rfv1" runat="server" Display="Dynamic" ControlToValidate="txt_grd_Name"
                                    ValidationGroup="grdFarmer" ForeColor="Red" Text="*" ErrorMessage="Enter name of farmer."></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Village Name" ItemStyle-Width="120px">
                            <ItemTemplate>
                                <%#Eval("Village") %>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txt_grd_Village" runat="server" Width="100px" Text='<%#Eval("Village") %>'></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfv2" runat="server" Display="Dynamic" ControlToValidate="txt_grd_Village"
                                    ValidationGroup="grdFarmer" ForeColor="Red" Text="*" ErrorMessage="Enter name of village."></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Phone No." ItemStyle-Width="120px">
                            <ItemTemplate>
                                <%#Eval("Phone_no") %>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txt_grd_Phone_no" runat="server" Width="100px" Text='<%#Eval("Phone_no") %>'></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfv3" ForeColor="Red" runat="server" Display="Dynamic"
                                    ControlToValidate="txt_grd_Phone_no" ValidationGroup="grdFarmer" Text="*" ErrorMessage="Enter phone number."></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Other Information" ItemStyle-Width="120px">
                            <ItemTemplate>
                                <%#Eval("Other_Info")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txt_Other_Info" runat="server" Width="100px" Text='<%#Eval("Other_Info") %>'></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfv4" ForeColor="Red" runat="server" Display="Dynamic"
                                    ControlToValidate="txt_Other_Info" ValidationGroup="grdFarmer" Text="*" ErrorMessage="Enter other information."></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Status" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="80px">
                            <ItemTemplate>
                                <asp:LinkButton ID="lbtn_Active" runat="server" OnClick="lbtn_Active_Click" Text='<%# Eval("IsActive").ToString() == "True" ? "Active" : "Inactive" %>'></asp:LinkButton>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <%# Eval("IsActive").ToString() == "True" ? "Active" : "Inactive" %>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Edit / Delete" ItemStyle-HorizontalAlign="Center"
                            ItemStyle-Width="150px">
                            <ItemTemplate>
                                <asp:LinkButton ID="lbtn_Edit" runat="server" CommandName="Edit" Text="Edit"></asp:LinkButton>
                                &nbsp;
                                <asp:LinkButton ID="lbtn_Delete" runat="server" OnClientClick="return confirm('Do you want to delete?')"
                                    OnClick="lbtn_Delete_Click" Text="Delete"></asp:LinkButton>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:LinkButton ID="lbtn_Update" ValidationGroup="grdFarmer" runat="server" CommandName="Update"
                                    Text="Update"></asp:LinkButton>
                                &nbsp;
                                <asp:LinkButton ID="lbtn_Cancel" runat="server" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                                <asp:ValidationSummary ID="vs1" ValidationGroup="grdFarmer" ShowSummary="false" ShowMessageBox="true"
                                    runat="server" />
                            </EditItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <AlternatingRowStyle BackColor="LightGray" />
                    <HeaderStyle BackColor="DarkGray" ForeColor="Black" />
                </asp:GridView>
            </td>
        </tr>
    </table>
</asp:Content>
